import React, { Component } from 'react';
//预约记录
import img1 from "../../style/images/jilu-pic1.jpg"
import * as tools from '../../config/tools'
import * as api from '../../config/api.js'
import '../hospitallist/hospitallist.css'

class Record extends Component {
  constructor(){
    super();
    this.state = {
        orderCheckUpList: [],
        pagerno:'1',
        condition:''
    }
  }
  componentDidMount() {
    this.show()
  }
  show(){
    let parmas={
        pagerno:this.state.pagerno,
        condition:this.state.condition
    }
    api.selectOrderCheckUpList(parmas).then((data)=>{
      if(data.result==='RC100'){
        this.setState({
        orderCheckUpList:data.orderCheckUpList,
      })
      }else{
        tools.toast.error(data.result)
      }
      
    })
  }
  Reservations(item){
    this.props.history.push(`/reservations/${item.checkUpOrderId}`)
  }
  render() {
    return (
           <div className='hospitallist'>
              <header className="mui-bar mui-bar-nav">
			<h1 className="mui-title">预约记录列表</h1>
		</header>
		<div className="mui-content">
      <div className="jilu-search">
      <div className="mui-search mui-active">
      <input type="search" 
      className="search_input mui-input-clear mui-indexed-list-search-input" 
      placeholder=""
      value={this.state.condition} onChange={(e)=>this.setState({condition:e.target.value})} />
      <button className='search_btn' onClick={()=>this.show()} >搜索</button>
      </div>
      </div>            
      </div>
        <div className="mui-content mui-content-all">
            {this.state.orderCheckUpList.map((item,index)=>{
                return(
                      <div key={index} className="jilu-list shade" onClick={()=>this.Reservations(item)}>
                          <li className="mui-table-view-cell">
                              <a className="mui-navigate-right d31145" open-type="common">
                                 {(() => {
                              switch (item.statusId) {
                              case '01':
                                  return '待预约';
                              case '02':
                                  return '已预约';
                              case '03':
                                  return '取消预约';
                              case '04':
                                  return '已发医院';
                              case '05':
                                  return '已逾期';
                              case '06':
                                  return '已体检';
                              case '07':
                                  return '报告回齐';
                              case '08':
                                  return '取消体检';
                              default:
                                  return ''
                              }
                          })()}
                              </a>
                          </li>
                          <dl>
                              <dt><img alt='img' src={img1} className="width100" /></dt>
                              <dd>
                                  <p className="p1">{item.personName}</p>
                                  <p className="p2">{item.partyName}</p>
                                  <p className="p3">{item.orderSubmitTime}</p>
                              </dd>
                          </dl>                
                      </div>
                    )
            })}
		</div>
    	</div>
    );
  }
}

export default Record;